#ifndef __SIMSUPERS_H__
#define __SIMSUPERS_H__

#include <typeinfo>
#include <map>

class NoSuper {
};

// We can't use util/Map here because Map.h includes Pool.h includes
// us so at some point we are included without the Map class being
// defined.  We could just define it here, but then the compiler
// doesn't know about Map::insert for the SetSuper() functions below,
// and it just becomes a mess. So we just use std::map. This should be
// fine because all of its memory allocation should happen at load
// time, so it is kind of "static",
typedef std::map<const std::type_info*, const std::type_info*> TypeMap; 
TypeMap& simSupers();

// This hack just gets the SetSuper() function to run at load time

#define SET_SUPER_H(ClassName,SuperClass)                       \
    struct SetSuper {                                           \
        SetSuper() {                                            \
            const std::type_info *type = &typeid(ClassName);    \
            const std::type_info *super = &typeid(SuperClass);  \
            simSupers()[type] = super;                          \
        }                                                       \
    };                                                          \
    static SetSuper setSuper;                                   \
    

#define SET_SUPER_CPP(ClassName)                \
    ClassName::SetSuper ClassName::setSuper;

bool is_a (const std::type_info &a, const std::type_info &b);

#endif // __SIMSUPERS_H__
